package top.arryweb.application.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import top.arryweb.application.common.exception.BusinessRuntimeException;

/**
 * @author xiong04
 * @since 2021-05-02
 */
@Getter
@AllArgsConstructor
public enum CapitalType {

	EXPENDITURE(1,"支出","expenditure"),
	INCOME(2,"收入","income");

	private final Integer rank;

	private final String comments;

	private final String name;

	public static CapitalType setRank(int rank){
		return Arrays.stream(CapitalType.values()).filter(capitalType -> capitalType.rank == rank).findFirst()
				.orElseThrow(() -> new BusinessRuntimeException("无此资金类型"));
	}
}
